<template>
	<!-- 订单卡片 -->
	<view class="sh-order-box u-flex u-m-b-10 ">
		<view class="order-box u-flex">
			<view class="order-item u-flex-col " @tap="jump('/pages/order/list', { type: order.type })"
				v-for="(order,index) in orderNav" :key="order.id">
				<view class="u-flex-col item-box u-col-center">
					<image class="order-img" :src="order.img" mode=""></image>
					<text class="item-title">{{ order.title }}</text>
					<view class="badge" v-if="index==0  && PendingPay>0">{{PendingPay}}</view>
					<view class="badge" v-if="index==1  && Pendingship>0">{{Pendingship}}</view>
					<view class="badge" v-if="index==2  && shippend>0">{{shippend}}</view>
					<view class="badge" v-if="index==3  && receied>0">{{receied}}</view>
				</view>
			</view>
			<view class="order-item u-flex-col " @tap="jump('/pages/order/after-sale/list')">
				<view class="u-flex-col item-box u-col-center">
					<image class="order-img" src="https://image.hzwltb69.com/app/images/aftersale.png"></image>
					<text class="item-title">售后/退款</text>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	/**
	 * 订单中心卡片
	 *
	 */
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		components: {},
		data() {
			return {
				orderNav: [{
						id: 1,
						title: '待付款',
						img: '../../static/images/waitpay.png',
						type: 'PENDING_PAYMENT'
					},
					{
						id: 2,
						title: '待发货',
						img: '../../static/images/waitsend.png',
						type: 'PENDING_SHIPMENT'
					},
					{
						id: 3,
						title: '待收货',
						img: '../../static/images/waitrec.png',
						type: 'SHIPPED'
					},
					{
						id: 4,
						title: '已完成',
						img: '../../static/images/waitcom.png',
						type: 'COMPLETED'
					}
					// {
					// 	id: 5,
					// 	title: '退换货',
					// 	img: this.$IMG_URL + '/imgs/user/tab55.png',
					// 	type: 'aftersale'
					// }
				],
				Pendingship: 0,
				receied: 0,
				shippend: 0,
				PendingPay: 0,
			};
		},

		mounted() {
			this.init();
		},
		onLoad() {
			this.init();
		},
		onShow() {
			this.init();
		},
		computed: {},
		methods: {
			init() {
				let that = this;
				that.$http('order.getcount', {
					UId: uni.getStorageSync("UId")
				}).then(res => {
					//等待发货
					that.Pendingship = res.data.shipmentNum
					//已完成 已弃用
					that.receied = res.data.completedNum
					//待收货
					that.shippend = res.data.shippedNum
					//待付款
					that.PendingPay = res.data.paymentNum

				});
			},
			jump(path, query) {
				this.$Router.push({
					path: path,
					query: query
				});
			}
		}
	};
</script>

<style lang="scss">
	.badge {

		position: absolute;
		/* #ifndef APP-NVUE */
		display: inline-flex;
		/* #endif */
		justify-content: center;
		align-items: center;
		line-height: 28rpx;
		padding: 4rpx 10rpx;
		border-radius: 100rpx;
		font-size: 24rpx;
		z-index: 9;
		background-color: $u-type-error;
		transform: scale(0.8);
		transform-origin: center center;
		left: 84rpx;
		top: -10rpx;
		color: #fff;
		white-space: nowrap;
	}

	// 订单卡片
	.sh-order-box {
		height: 180rpx;
		background: url("https://image.hzwltb69.com/app/images/backorder.png") no-repeat center / 100% 100%;

		width: 700rpx;
		margin-left: 25rpx;
		border-radius: 25rpx;

		.order-box {
			flex: 4;
		}

		.all-order {
			position: relative;

			.cut-off--line {
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				right: (750rpx/5) - 15rpx;
				width: 30rpx;
				height: 136rpx;
			}
		}

		.order-item {
			flex: 1;

			.item-box {
				position: relative;
			}

			.order-img {
				width: 46rpx;
				height: 46rpx;
			}

			.item-title {
				font-size: 26rpx;
				font-weight: 500;
				color: rgba(153, 153, 153, 1);
				line-height: 24rpx;
				margin-top: 20rpx;
			}
		}
	}
</style>
